home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Resources / Chat & Communication / Digsby build 37 / digsby_setup.exe / lib / jabber / JabberContact.pyo (.txt) < prev    next >
Python Compiled Bytecode  |  2008-10-13  |  4KB  |  94 lines

  1. # Source Generated with Decompyle++
  2. # File: in.pyo (Python 2.5)
  3.  
  4. from common.actions import ActionMeta
  5. import jabber
  6. import common.actions as common
  7. from common.actions import action
  8. import contacts
  9. from util import callsback
  10. import logging
  11. log = logging.getLogger('jabber.contact')
  12. contact_attrs = ('watched', 'buddy_changed', '__repr__', 'group', 'buddy', 'remove_from_group')
  13.  
  14. no_widget = lambda self, *a, **k: None if getattr(self.buddy, 'iswidget', False) else True
  15. cgetattr = contacts.Contact.__getattribute__
  16. objget = object.__getattribute__
  17.  
  18. class JabberContact(common.actions.ActionType, contacts.Contact):
  19.     inherited_actions = [
  20.         jabber.jbuddy]
  21.     __metaclass__ = ActionMeta
  22.     
  23.     def __init__(self, buddy, group):
  24.         self.group = group
  25.         contacts.Contact.__init__(self, buddy, buddy.id)
  26.  
  27.     
  28.     def send_sms(self):
  29.         raise TypeError('Jabber does not support SMS at this time')
  30.  
  31.     send_sms = action((lambda self: pass))(send_sms)
  32.     
  33.     def remove(self, callback = None):
  34.         if len(self.buddy.groups) <= 1:
  35.             return self.buddy.remove(callback = callback)
  36.         else:
  37.             return self.remove_from_group(callback = callback)
  38.  
  39.     remove = action(no_widget)(callsback(remove))
  40.     
  41.     def rename_gui(self):
  42.         return contacts.Contact.rename_gui(self)
  43.  
  44.     rename_gui = action(no_widget)(rename_gui)
  45.     
  46.     def remove_from_group(self, callback = None):
  47.         log.info('remove_from_group %s: %s', self.group, self)
  48.         item = self.protocol.roster.get_item_by_jid(self.id).clone()
  49.         item.groups.remove(self.group)
  50.         query = item.make_roster_push()
  51.         self.protocol.send_cb(query, callback = callback)
  52.  
  53.     remove_from_group = callsback(remove_from_group)
  54.     
  55.     def replace_group(self, new_group, callback = None):
  56.         item = self.protocol.roster.get_item_by_jid(self.id).clone()
  57.         if self.group is not None:
  58.             item.groups.remove(self.group)
  59.         
  60.         if new_group not in item.groups:
  61.             item.groups.append(new_group)
  62.         
  63.         query = item.make_roster_push()
  64.         self.protocol.send_cb(query, callback = callback)
  65.  
  66.     replace_group = callsback(replace_group)
  67.     
  68.     def view_past_chats(self, *a, **k):
  69.         self.buddy.view_past_chats(*a, **k)
  70.  
  71.     view_past_chats = action(no_widget)(view_past_chats)
  72.     
  73.     def __iter__(self):
  74.         return iter(self.buddy)
  75.  
  76.     
  77.     def __getattr__(self, attr):
  78.         if attr in contact_attrs:
  79.             return cgetattr(self, attr)
  80.         else:
  81.             return getattr(cgetattr(self, 'buddy'), attr)
  82.  
  83.     
  84.     def __repr__(self):
  85.         return '<JabberContact %s>' % self.buddy.name
  86.  
  87.     
  88.     def block(self):
  89.         pass
  90.  
  91.     block = action((lambda self: pass))(block)
  92.     unblock = block
  93.  
  94.